<template>
  <div class="brand-detail">
    <nav-bar title="专题"></nav-bar>
    <div class="banner">
      <img :src="brandData.app_list_pic_url" alt="" />
      <p>{{ brandData.name }}</p>
    </div>
    <div class="desc">
      <p>{{ brandData.simple_desc }}</p>
    </div>
    <div class="goods-list">
      <p class="goods-none" v-if="goodsList.length === 0">数据库暂无数据</p>
      <ul class="list">
        <li
          class="item"
          v-for="(item, index) in goodsList"
          :key="index"
          @click="toGoods(item.id)"
        >
          <img :src="item.list_pic_url" alt="" />
          <p class="title">{{ item.name }}</p>
          <p class="price">￥{{ item.retail_price }}</p>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { getBrandDetail } from "@/api/pages/branddetail";
import NavBar from "@/components/common/nav-bar";
export default {
  data() {
    return {
      id: this.$route.query.id,
      brandData: {},
      goodsList: [],
    };
  },
  methods: {
    getData() {
      getBrandDetail({ id: this.id }).then((res) => {
        console.log(res);
        this.brandData = res.data;
        this.goodsList = res.goodsList;
      });
    },
    toGoods(id) {
      this.$router.push({ path: "/pages/goods/goods", query: { id: id } });
    },
  },
  created() {
    this.getData();
  },
  components: {
    "nav-bar": NavBar,
  },
};
</script>

<style lang="scss" scoped>
.brand-detail {
  .banner {
    position: relative;
    width: 100%;
    height: 140px;
    img {
      height: 100%;
      width: 100%;
    }
    p {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      border-bottom: 3px solid #fff;
      font-size: 18px;
      color: #fff;
    }
  }
  .desc {
    padding: 20px 15px;
    box-sizing: border-box;
    height: 100px;
    width: 100%;
    background-color: #fff;
    p {
      font-size: 15px;
      color: #666;
      text-align: center;
    }
  }
  .goods-list {
    position: relative;
    min-height: 300px;
    .goods-none {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
    .list {
      margin-top: 10px;
      width: 100%;
      .item {
        float: left;
        width: 50%;
        height: 225px;
        border-right: 1px solid #d9d9d9;
        border-bottom: 1px solid #d9d9d9;
        text-align: center;
        box-sizing: border-box;
        background: #fff;
        img {
          display: block;
          margin: 0 auto;
          width: 150px;
          height: 150px;
        }
        .price {
          margin-top: 15px;
          font-size: 14px;
          color: #b4282d;
        }
      }
    }
  }
}
</style>